package com.itheima.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpSession;

public class SecurityUtils {
    public static HttpSession getSession() {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession();
    }

    public static void setSessionAttribute(String name, Object value) {
        getSession().setAttribute(name, value);
    }

    public static Object getSessionAttribute(String name) {
        return getSession().getAttribute(name);
    }
}